﻿using System;
using System.IO;
using System.Text;
using Crm2011.Framework.Core;



namespace ScriptEase
{
    /// <summary>
    /// A class to compare the content of the WebResource 
    /// bit-wise with the file content.
    /// </summary>
    class FileComparer : IFileComparer
    {
        public void Initialize(WorkspaceManager workspaceManager)
        {
            _workspaceManager = workspaceManager;
        }

        private WorkspaceManager _workspaceManager;


        public bool AreEqual(string filePath, WebResource webResource)
        {
            string webResourceContent = (webResource.Content!=null) ? FileEncoding.DecodeFrom64(webResource.Content) : String.Empty;
            string localFileContent = File.ReadAllText(filePath, Encoding.UTF8);
            return webResourceContent == localFileContent;
        }
    }
}